const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

// 分组列表
const participants = ["号码1", "号码2", "号码3", "号码4", "号码5"];

// GET 请求端点，用于抓阄
app.get('/draw-lots', (req, res) => {
    if (participants.length === 0) {
        res.status(400).json({ error: "参与者列表为空，无法进行抓阄。" });
        return;
    }

    // 随机选择一个号码
    const randomIndex = Math.floor(Math.random() * participants.length);
    const winner = participants[randomIndex];

    // 返回抓阄结果
    res.json({ winner });
});

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on port ${PORT}`);
});
